package ctxop

import (
	"context"
	models "wx-uniapp-go/internal/repository/models"
)

func UserSet(ctx context.Context, user *models.User) context.Context {
	return context.WithValue(ctx, keyUserInfo{}, user)
}

// GetUser 获取 用户系统信息，记得判断是否 nil
func GetUser(ctx context.Context) *models.User {
	v, ok := ctx.Value(keyUserInfo{}).(*models.User)
	if !ok {
		return &models.User{}
	}
	return v
}
